package com.yibo.redis.properties;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import static com.yibo.redis.constant.RedisConstant.REDIS_PROPERTIES;

@Configuration
@ConfigurationProperties(REDIS_PROPERTIES)
public class RedisProperties {

    /**
     * 数据库  一共15个数据库 默认选第0 个
     */
    private int database = 0;


    private int secondaryDataBase = 1;

    /**
     * 地址
     */
    private String url;

    /**
     * host 域名 默认本地
     */
    private String host = "localhost";

    /**
     * 密码
     */
    private String  password;


    /**
     * 端口  默认 6379
     */
    private int port = 6379;


    private boolean  ssl;

    /**
     * 连接超时时间
     */
    private  int timeout;

    private Pool pool;

    public int getDatabase() {
        return database;
    }

    public void setDatabase(int database) {
        this.database = database;
    }

    public int getSecondaryDataBase() {
        return secondaryDataBase;
    }

    public void setSecondaryDataBase(int secondaryDataBase) {
        this.secondaryDataBase = secondaryDataBase;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public boolean isSsl() {
        return ssl;
    }

    public void setSsl(boolean ssl) {
        this.ssl = ssl;
    }

    public int getTimeout() {
        return timeout;
    }

    public void setTimeout(int timeout) {
        this.timeout = timeout;
    }

    public Pool getPool() {
        return pool;
    }

    public void setPool(Pool pool) {
        this.pool = pool;
    }

    public static class Pool{

        private  int maxIdle = 50;

        private  int minIdle = 0;

        private  int maxActive = 200;

        private  int maxWait = 10000;

        public int getMaxIdle() {
            return maxIdle;
        }

        public void setMaxIdle(int maxIdle) {
            this.maxIdle = maxIdle;
        }

        public int getMinIdle() {
            return minIdle;
        }

        public void setMinIdle(int minIdle) {
            this.minIdle = minIdle;
        }

        public int getMaxActive() {
            return maxActive;
        }

        public void setMaxActive(int maxActive) {
            this.maxActive = maxActive;
        }

        public int getMaxWait() {
            return maxWait;
        }

        public void setMaxWait(int maxWait) {
            this.maxWait = maxWait;
        }
    }


}
